package com.translate.web.api.controller;

import javax.servlet.http.HttpServletRequest;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.NativeWebRequest;

import com.param.impl.IdPageParam;
import com.translate.vo.NoticeReadedVO;
import com.response.vo.ResponseModel;
import com.controller.base.AbstractCommonController;
import com.translate.web.param.NoticeReadedUpdateParam;
import com.translate.web.param.NoticeReadedAddParam;
import com.translate.entity.NoticeReaded;
import com.translate.web.service.INoticeReadedService;
import com.basic.service.contract.IBaseService;

@RestController
@RequestMapping("noticeReaded")
public class NoticeReadedController extends AbstractCommonController<NoticeReaded, IdPageParam> {
	private INoticeReadedService service;

	public NoticeReadedController(INoticeReadedService service) {
		this.service = service;
	}

	/**
	 * 添加
	 * @param <V>
	 * @param param
	 * @return
	 */
	@PostMapping("/add")
	public ResponseModel<Integer> insert(@RequestBody @Validated NoticeReadedAddParam param,
			NativeWebRequest httpServletRequest) {

		param.setUserId(this.getUserId(httpServletRequest));
		
		int id = this.service.parseInsert(param, NoticeReaded.class);

		return ResponseModel.<Integer>success(id);
	}

	@Override
	protected IBaseService<NoticeReaded> getBaseService() {
		return this.service;
	}

	/**
	 * 添加
	 * 
	 * @param <V>
	 * @param param
	 * @return
	 */
	@PostMapping("/update")
	public ResponseModel<Integer> update(@Validated @RequestBody NoticeReadedUpdateParam param,
			HttpServletRequest httpServletRequest) {
		int res = this.service.parseUpdate(param, NoticeReaded.class);
		return ResponseModel.<Integer>success(res);
	}

	protected <VO> Class<VO> getTarget() {
		return (Class<VO>) NoticeReadedVO.class;
	}
}